<!doctype html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>HTML5 canvas支持触摸屏的签名涂鸦插件|DEMO_jQuery之家-自由分享jQuery、html5、css3的插件库</title>
	<link rel="stylesheet" href="http://libs.useso.com/js/bootstrap/3.2.0/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/default.css">
	<!--[if IE]>
		<script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->
</head>
<body>
	<div class="htmleaf-container">
		<div class="container">
			<div class="row">
				<div class="col-xs-12" >
					<h3>基本例子：</h3>
					<p>Sign Below:</p>
					<div class="js-signature"></div>
				</div>
			</div>
			<div class="row">
					<div class="col-xs-12">
						<h3>高级例子：</h3>
						<p>Sign Below:</p>
						<div class="js-signature" data-width="600" data-height="200" data-line-width="5" data-border="1px solid black" data-background="yellow" data-line-color="#AC21FF" data-auto-fit="true"></div>
						<p><button id="clearBtn" class="btn btn-default" onclick="clearCanvas();">清除 Canvas</button>&nbsp;<button id="saveBtn" class="btn btn-default" onclick="saveSignature();" disabled>保存 Signature</button></p>
						<div id="signature">
						</div>
					</div>
			</div>
		</div>
	</div>
	<input type="hidden" value="" id="js-img">
	<script async src="http://libs.useso.com/js/jquery/1.11.0/jquery.min.js"></script>
	<script src="js/jq-signature.js"></script>
	<script type="text/javascript">
		$(document).on('ready', function() {
			if ($('.js-signature').length) {
				$('.js-signature').jqSignature();
			}
		});
		function clearCanvas() {
			$('#signature').html('<p><em>Your signature will appear here when you click "Save Signature"</em></p>');
			$('.js-signature').eq(1).jqSignature('clearCanvas');
			$('#saveBtn').attr('disabled', true);
		}

		function saveSignature() {
			$('#signature').empty();
			var dataUrl = $('.js-signature').eq(1).jqSignature('getDataURL');
			var img = $('<img>').attr('src', dataUrl);
			$("#js-img").val(dataUrl);
			$('#signature').append($('<p>').text("Here's your signature:"));
			$('#signature').append(img);

			$.post("uplode.php",{img:dataUrl},function (data) {
				console.log(data);
			},'JSON')
		}

		$('.js-signature').eq(1).on('jq.signature.changed', function() {
			$('#saveBtn').attr('disabled', false);
		});

	</script>
</body>
</html>